package com.permutation;

import java.io.*;

public class Common{
	
	public static final int[] POWER = {0, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 1932053504, 1278945280, 2004310016, 2004189184};
	public static String[] ascendString;
	
	public static File file;
	public static FileWriter fw;
    public static BufferedWriter bw;
    
    
	public static long begin;
	public static long end;
	
	
	public static String[] sortAscending(String[] orig)
	{
		String[] ascend = new String[orig.length];
		for(int i = 0; i < orig.length; i++)
			ascend[i] = orig[i];
		
		int j;  
        for(int p = 1; p < orig.length; p++){  
            String key = ascend[p];  
            for(j = p; j > 0 && (key.compareTo(ascend[j-1]) > 0); j--)  
            	ascend[j] = ascend[j-1];  
            ascend[j] = key;  
        }  
		
		return ascend;
		
	}
	
	public static void printReverse(String[] s)
	{
		for(int i = s.length - 1; i > 0; i--)
			System.out.print(s[i] + " ");
		
		System.out.println(s[0]);
	}
	
	
	public static void writeReverse(String[] s) throws IOException
	{
		for(int i = s.length - 1; i > 0; i--)
		{
			//System.out.print(s[i] + " ");
			bw.append(s[i] + " ");
		}
		
		bw.append(s[0] + "\n");
		
		//System.out.println(s[0]);
	}
	
	public static void printReverse(int[] s)
	{
		for(int i = s.length - 1; i > 0; i--)
			System.out.print(s[i] + " ");
		System.out.println(s[0]);
	}
}